package manage.actions.example;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import manage.actions.ManageAction;
import manage.modules.mail.model.MailBean;
import manage.modules.mail.service.MailService;

public class MailAction extends ManageAction {

	private static final long serialVersionUID = -5456179172847870350L;
	private MailService mailService;
	private MailBean mailBean;

	@Override
	@Action("mail-input")
	public String input() throws Exception {
		return SUCCESS;
	}

	@Override
	@Action(value = "mail", results = { @Result(name = SUCCESS, location = "/example/mail-input.jsp") })
	public String execute() throws Exception {
		mailService.sendMail(mailBean);
		request.setAttribute("msg", "邮件发送成功");
		return SUCCESS;
	}

	public void setMailService(MailService mailService) {
		this.mailService = mailService;
	}

	public void setMailBean(MailBean mailBean) {
		this.mailBean = mailBean;
	}

	public MailBean getMailBean() {
		return mailBean;
	}

}
